const path = require("path");

const entry = {
    "libs/jquery" : "jquery",
    "scripts/index" : "./src/routes/index/index.js",
    "scripts/login": "./src/routes/login/login.js",
    "scripts/register": "./src/routes/register/register.js",
    "scripts/orderCart": "./src/routes/orderCart/orderCart.js",
    "scripts/active": "./src/routes/active/active.js"
}

const output = {
      path : path.resolve(__dirname,"../dev"),
      filename : "[name]-[hash:4].js"
}

// 处理html
const htmlPlugin = [
    {
        filename : "index.html",
        template : "./src/routes/index/index.html",
        chunks: ['scripts/index']
    }
    ,
    {
        filename : "header.html",
        template : "./src/parts/inc/header.html",
        chunks: [],
    }
    ,
    {
        filename : "footer.html",
        template : "./src/parts/inc/footer.html",
        chunks: [],
    }
    ,
    {
        filename : "login.html",
        template : "./src/routes/login/login.html",
        chunks: ['scripts/login']
    }
    ,
    {
        filename : "register.html",
        template : "./src/routes/register/register.html",
        chunks: ['scripts/register']
    }
    ,
    {
        filename : "orderCart.html",
        template : "./src/routes/orderCart/orderCart.html",
        chunks: ['scripts/orderCart']
    }
    ,
    {
        filename : "active.html",
        template : "./src/routes/active/active.html",
        chunks: ['scripts/active']
    }
]

// 将jquery等插件全局化
const providePlugin = [
    // {
    //     $: "jquery",
    //     jQuery: "jquery",
    //     jquery: "jquery",
    //     "window.jQuery": "jquery"
    // }
];

// copy
const copyPlugin = [
    {
        "from": "./src/server",
        "to": "server"
    }
    ,
    {
        "from": "./src/images",
        "to": "images"
    }
]

// 服务器代理配置;
const proxyList = {
    "/pxx" : {
        url : "https://apiv2.pinduoduo.com/api/fiora/subject/goods/",
        // 默认重写路径
        // rewrite : true
    },
    "/dt" :{
        url : "https://www.duitang.com/napi/blog/list/by_filter_id/"
    },
    "/winekee": {
        url : "http://10.9.65.244/winekee-server/static"
    }
}

// 自动打开html
const openBrowser = { url: 'http://localhost:8888' };

module.exports = {
    entry,
    output,
    htmlPlugin,
    providePlugin,
    openBrowser,
    proxyList,
    copyPlugin
}